package cn.rocky.prepare;

import java.util.HashSet;
import java.util.Set;

/**
 * 6171. 和相等的子数组
 */
public class findSubarrays {


    public static boolean findSubarrays(int[] nums) {
        int length = nums.length;
        boolean flag = false;
        if (length < 2) { return flag;}
        Set<Object> set = new HashSet<>();
        for (int i = 1; i < length; i++) {
            int sum = nums[i - 1] + nums[i];
            if (!set.add(sum)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    public static void main(String[] args) {
        int[] nums1 = new int[]{4, 2, 4};
        int[] nums2 = new int[]{1, 2, 3, 4, 5};
        int[] nums3 = new int[]{0, 0, 0};
        int[] nums4 = new int[]{1,0, 1, 0};
        int[] nums5 = new int[]{-1,0,1,-2};
        System.out.println(findSubarrays(nums1));
        System.out.println(findSubarrays(nums2));
        System.out.println(findSubarrays(nums3));
        System.out.println(findSubarrays(nums4));
        System.out.println(findSubarrays(nums5));
    }
}
